﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using BadmintonApp.Entity;
using BadmintonApp.Factory;
using BadmintonApp.BLL.Interface;
using BadmintonApp.DAO.Interface;

namespace BadmintonApp.BLL.Implement
{
    public class UsersBLL : IUsersBLL
    {
        private IUsersDAO dao;

        /// <summary>
        /// 默认的构造函数
        /// </summary>
        public UsersBLL()
        {
            dao = DaoFactory.CreateUsersDAO();
        }

        #region IUsersBLL Members

        /// <summary>
        /// 插入用户信息
        /// </summary>
        /// <param name="userInfo">用户信息类</param>
        /// <returns>是否成功插入</returns>
        public bool InsertUser(TUsersInfo userInfo)
        {
            return dao.InsertUser(userInfo);
        }

        /// <summary>
        /// 更新用户信息
        /// </summary>
        /// <param name="userInfo">用户信息类</param>
        /// <returns>是否成功更新</returns>
        public bool UpdateUser(TUsersInfo userInfo)
        {
            return dao.UpdateUser(userInfo);
        }

        /// <summary>
        /// 删除用户信息
        /// </summary>
        /// <param name="userID">用户ID</param>
        /// <returns>是否成功删除</returns>
        public bool DeleteUser(int userID)
        {
            return dao.DeleteUser(userID);
        }

        /// <summary>
        /// 根据名称获取用户信息
        /// </summary>
        /// <param name="userName">用户名称</param>
        /// <returns>用户信息类</returns>
        public TUsersInfo GerUserInfo(string userName)
        {
            return dao.GerUserInfo(userName);
        }

        /// <summary>
        /// 根据用户名称和密码获取用户信息
        /// </summary>
        /// <param name="userName">用户名称</param>
        /// <param name="password">密码</param>
        /// <returns>用户信息类</returns>
        public TUsersInfo GetUserInfoByNameAndPassword(string userName, string password)
        {
            return dao.GetUserInfoByNameAndPassword(userName, password);
        }

        public DataSet GetAllUsers()
        {
            return dao.GetAllUsers();
        }

        #endregion
    }
}
